/* Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This file is a part of the CANN Open Software.
 * Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 * ===================================================================================================================*/
#include "acl_rec.h"
#include "acl/acl_mdl.h"

namespace aclrec {
Model::~Model() {
  if (bundle_model_id_ != kInvalidModelId) {
    ASSERT_ACL_SUCCESS(aclmdlBundleUnload(bundle_model_id_));
  }
}
std::unique_ptr<Model> Model::LoadFromFile(const std::string& file_path) {
  auto model = std::unique_ptr<Model>(new Model());
  ASSERT_ACL_SUCCESS(aclmdlBundleLoadFromFile(file_path.c_str(), &model->bundle_model_id_));

  size_t model_num;
  ASSERT_ACL_SUCCESS(aclmdlBundleGetModelNum(model->bundle_model_id_, &model_num));
  ASSERT(model_num == 3, "The bundle model must have 3 models(infer, init, update)");

  // todo load init model
  // todo run init model
  // todo unload init model

  // todo load update model

  return model;
}
Model::Model() :  weight_updater_(*this) {}
}  // aclrec